/*
* @Author: dengjiayao
* @Date:   2017-12-15 16:09:00
* @Last Modified by:   dengjiayao
* @Last Modified time: 2017-12-20 20:09:37
*/
import Vue from './vue'
import store from './vuex/store'
import { alert } from 'vue-strap'
import loginCheck from './util/login-check'
import ClassesList from './classes/list/list.vue'
import ClassesConfig from './classes/config/config.vue'

new Vue({
  el: 'body',
  components: {
    'vue-alert-msg': alert,
    'vue-list': ClassesList,
    'vue-config': ClassesConfig
  },
  store,
  created() {
    loginCheck(this)
  },
  vuex: {
    getters: {
      msg: state => state.msg
    }
  },
  methods: {
    addItem() {
      let ref = this.$refs.classesConfig
      let fileFields = ['listPicFile', 'headPicFile', 'shopPicFile', 'timetablePicFile']
      for (let k of fileFields) {
        ref.$els[k].value = ''
      }
      ref.actionType = 'ADD'
      ref.form = {
        top: 0,
        title: '',
        summary: '',
        listPicUrl: '',
        headPicUrl: '',
        shopPicUrl: '',
        shopUrl: '',
        topicId: '',
        frequency: '',
        highlights: '',
        timetablePicUrl: '',
        lecturerIntro: '',
        suitableFor: ''
      }
      ref.showModal = true
    }
  }
})
